home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SoundMaker 2003 (Professional Edition)
/
SoundMaker 2003 - Professional Edition.iso
/
midi tool
/
midioxse.exe
/
DATA.1
/
Polychord.vbs
< prev
next >
Wrap
Text File
|
1999-11-26
|
3KB
|
128 lines
' MIDIOX Test
' Copyright (c) 2000 by Jamie O'Connell
'
' This script is an example of doing VBScript with MIDI-OX
' It puts each successive held note on a different MIDI channel
option explicit
dim mox
dim str, strWrk, strSysEx
dim n, ii, nInst
dim bGo, bFound
dim notesOn
dim baseChan
dim aryOn(10)
' Create object
Set mox = WScript.CreateObject("MoxKart.MoxWire.1", "On_")
n = mox.NumberInstances
If n > 0 Then
nInst = 1
If n > 1 Then
nInst = InputBox( "Attach to which instance? (1 to " & n & ")", "Attach", "1" )
End If
If mox.AttachInstance( nInst ) = 1 Then
MsgBox "Attached Instance: " & nInst
Else
MsgBox "Could not Attach Instance: " & nInst
End If
ElseIf mox.LaunchInstance = 1 Then
nInst = 1
If mox.AttachInstance( nInst ) = 1 Then
MsgBox "Launched and Attached Instance: " & nInst
Else
MsgBox "Launched but could not Attach Instance: " & nInst
End If
Else
MsgBox "Launch MIDI-OX Failed"
End If
n = mox.NumberInstances
For ii = 0 to 9
aryOn(ii) = -1
Next
' *** Try out our MIDI Input loop
notesOn = 0 ' init
baseChan = 0 ' init -- we expect channel 1
If mox.IsAttached = 1 then
mox.DivertMidiInput = 1
mox.FireMidiInput = 1
MsgBox "Press OK to end PolyChord MIDI Loop"
mox.FireMidiInput = 0
mox.DivertMidiInput = 0
End If
Set str = nothing
Set strWrk = nothing
Set mox = nothing
' Exit Point
'------------------------------------------
Sub On_MidiInput( ts, stat, chan, dat1, dat2)
dim newStat, newChan
newChan = chan
If chan = baseChan Then
If stat = &h90 And dat2 > 0 Then ' Note On
If aryOn( notesOn ) = -1 Then ' Use this One
aryOn( notesOn ) = dat1
newChan = notesOn
Else
bFound = false
For ii = 0 to 10
If aryOn( ii ) = -1 Then
aryOn( ii ) = dat1
newChan = ii
bFound = true
Exit For
End If
Next
If bFound = false then
aryOn( notesOn ) = dat1
newChan = notesOn
End If
End If
notesOn = notesOn + 1 ' the next note on will be on the next channel
ElseIf (stat = &h90 And dat2 = 0) Or stat = &h80 Then ' Note Off
If aryOn( notesOn ) = dat1 Then ' Use this One
aryOn( notesOn ) = -1
newChan = notesOn
Else
For ii = 10 to 0 step -1
If aryOn( ii ) = dat1 Then
aryOn( ii ) = -1
newChan = ii
Exit For
End If
Next
End If
notesOn = notesOn - 1 ' next note goes on previous channel
End If
If newChan > 15 Then ' sanity check
newChan = 0
End If
End If
newStat = stat + newChan ' send out next chan
mox.OutputMidiMsg newStat, dat1, dat2
End Sub
'------------------------------------------
' connection point sink for SysEx
Sub On_SysExInput( strSysEx )
mox.SendSysExString strSysEx
End Sub